using UnityEngine;

public class MainMenuLayer : UILayer
{
	public UIScrollView scroll;

	public Transform singleplayerTab;

	public Transform multiplayerTab;

	private Transform firstTab;

	protected int alignedCount;

	public PointTo hand;

	public InterstitialAdLayer adLayer;

	protected bool shownInterstitialAd;

	public static bool hasShownPromo;

	private void Awake()
	{
		BehaviourSingletonInit<Notifications>.instance.ClearNotifications();
		Ads.instance.createBanner();
		GGNetwork.instance.StopServer();
		Screen.sleepTimeout = -2;
	}

	private void OnEnable()
	{
		firstTab = multiplayerTab;
		if (!GGPlayerSettings.instance.Model.multiplayerMatchPlayed)
		{
			hand.StartPointing(multiplayerTab, new Vector3(0.1f, -0.1f, 0f));
		}
		else
		{
			hand.Hide();
		}
		Ads.instance.hideBanner(false);
		BehaviourSingleton<AdBundle>.instance.TryToRefreshBundle();
	}

	private void OnDisable()
	{
		hand.Hide();
	}

	private new void Update()
	{
		if (alignedCount < 4)
		{
			alignedCount++;
			if (alignedCount == 4)
			{
				UITools.CenterWidgetOnScroll(firstTab.GetComponent<UIWidget>(), scroll);
			}
		}
		if (isEntered && NavigationManager.instance.shouldGoBack)
		{
			UIDialog.instance.ShowYesNo("Exit App?", "Exit This App?", "Yes", "No", OnExit);
		}
		if (GGPlayerSettings.instance.Model.version < 1)
		{
			GGPlayerSettings.instance.UpdateModel();
		}
	}

	private void OnExit(bool success)
	{
		if (success)
		{
			BehaviourSingletonInit<Notifications>.instance.OnExitApp();
			Application.Quit();
		}
		NavigationManager.instance.Pop();
	}
}
